<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<body>
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-sm" lay-event="add_panel">新增</button>
		<button class="layui-btn layui-btn-sm" lay-event="update_panel">修改</button>
  	</div>
</script>
	<fieldset class="layui-elem-field layui-field-title site-title">
		<legend>
			<a name="fixbar" style="font-size: 16px; color: #ce2424;">课程评价</a>
		</legend>
	</fieldset>
	<form class="layui-form" id="myForm" method="post" lay-filter="stuform">
		<div class="layui-form-item">
			<div class="layui-inline" style="width: 350px;">
				<label class="layui-form-label">班级名称：</label>
				<div class="layui-input-block">
					<select id="bjid" lay-filter="bjselect" lay-verify="required"
						lay-search>
						<c:forEach var="d" items="${bjs}">
							<option value="${d.id}">${d.name}</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="layui-inline" style="width: 350px;">
				<label class="layui-form-label">课程名称：</label>
				<div class="layui-input-block">
					<select id="kc" lay-filter="kcselect" lay-search>
					</select>
				</div>
			</div>
			<div class="layui-inline" style="width: 350px;">
				<label class="layui-form-label">学员姓名：</label>
				<div class="layui-input-block">
					<select id="student" lay-filter="stuselect" lay-search>
					</select>
				</div>
			</div>
			
		</div>
	</form>

	<table class="layui-hide" id="evaluationInformation" lay-filter="evaluationInformation"></table>
	<script type="text/javascript">
		fun();
		layui.use('form', function(){
			var form = layui.form;
			form.render('select');
			
			form.on('select(bjselect)', function(data){
				resultFun();
				fun();
			})
			form.on('select(kcselect)', function(data){
				resultFun();
			})
			form.on('select(stuselect)', function(data){
				resultFun();
			})
		})
		
		function resultFun(){
			layui.use('table', function(){
				var table = layui.table;
				var bjid = $("#bjid").val();
				var kcid = $("#kc").val();
				var stuid = $("#stu").val();
				table.reload('evaluationInformation',{
					url: 'evaluationInformation/coursePage',
					where: {bjid: bjid, kcid: kcid, stuid: stuid}
				})
			})
		}
		
		function fun(){
			layui.use('form', function(){
				var form = layui.form;
				var bjid = $("#bjid").val();
				$("#kc").empty();
				$("#student").empty();
				$.post("evaluationInformation/stuSelect", {id: bjid}, function(data){
					$("#student").append('<option value=""></option>');
					for (var i = 0; i < data.length; i++) {
						var json = data[i];
						var str = ""; 
						str += '<option value="'+json.id+'">' + json.name
								+ '</option>';
						$("#student").append(str);
					}
					form.render('select');
				});
				$.post("evaluationInformation/kcSelect", {id: bjid}, function(data){
					$("#kc").append('<option value=""></option>');
					for (var i = 0; i < data.length; i++) {
						var json = data[i];
						var str = "";
						str += '<option value="'+json.id+'">' + json.curriculum.courseName
								+ '</option>';
						$("#kc").append(str);
					}
					form.render('select');
				});
			})
		}
		
		layui.use("table", function(){
			var table = layui.table;
			var bjid = $("#bjid").val();
			table.render({
				elem: '#evaluationInformation',
				url: 'evaluationInformation/coursePage',
				title: '课程评价',
				height: 'full-260',
				where: {bjid: bjid},
				page: true,
				cols: [[
					{field: 'grades', title: '评价等级'},
					{field:'evaluationRule',title:'课程点评',templet: function(d){
						return d.evaluationRule?d.evaluationRule.evaluation: '';
					}},
					{field:'evaluationRule',title:'课程名称',templet: function(d){
						return d.evaluationRule?d.evaluationRule.tbCurriculumCourseName: '';
					}},
					{field:'evaluationRule',title:'班级名称',templet: function(d){
						return d.evaluationRule?d.evaluationRule.tbClassName: '';
					}},
					{field:'evaluationRule',title:'任课老师',templet: function(d){
						return d.evaluationRule?d.evaluationRule.teacherName: '';
					}},
					{field:'evaluationRule',title:'学生姓名',templet: function(d){
						return d.evaluationRule?d.evaluationRule.studentname: '';
					}}
				]]
			})
		})
	
	</script>
</body>
